﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="PaySub.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：PaySub.cs
// 创建时间：2015-01-08 10:50
// 修改时间：2015-01-08 10:02
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

namespace Payment.ChinaPay
{
    #region

    using System.Collections.Generic;
    using System.Text;

    #endregion

    /// <summary>
    ///     银联下单
    /// </summary>
    public class PaySub : PaySubBase
    {
        #region Fields

        /// <summary>
        /// The operation.
        /// </summary>
        private PayOperation operation;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// 实例化一个订单提交
        /// </summary>
        /// <param name="operation">
        /// </param>
        public PaySub(PayService service, ChinaPayConfig config)
        {
            operation = new PayOperation(service, config);
            this.Gateway = "https://payment.chinapay.com/pay/TransGet";

        }

        #endregion

        #region Public Properties


        /// <summary>
        ///     Gets or sets the Service status.
        /// </summary>
        public string OrderStatus { get; set; }

        #endregion

        #region Public Methods and Operators


        protected override string Method()
        {
            return "post";
        }

        /// <summary>
        /// 写入subdata到集合
        /// </summary>
        /// <returns></returns>
        protected override Dictionary<string, string> GetSubData()
        {
            var data = new Dictionary<string, string>
                        {
                            { "MerId", this.operation.Service.MerId },
                            { "OrdId", this.operation.Service.OrdId },
                            { "TransAmt", this.operation.Service.TransAmt },
                            { "CuryId", this.operation.Service.CuryId },
                            { "TransDate", this.operation.Service.TransDate },
                            { "TransType", this.operation.Service.TransType },
                            { "Version", this.Version },
                            { "BgRetUrl",  this.operation.Service.NoticeUrl },
                            { "PageRetUrl", this.operation.Service.ReturnUrl },
                            { "GateId", string.Empty },
                            { "Priv1", this.operation.Service.Remarks },
                            { "ChkValue", this.operation.Sign() },
                        };
            return data;
        }

        #endregion

        /// <summary>
        /// 版本号
        /// </summary>
        public virtual string Version
        {
            get
            {
                return "20070129";
            }
        }
    }
}